package com.fancy.learncenter.ui.view.zxing.view;

import android.Manifest;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;

import com.fancy.learncenter.R;
import com.fancy.learncenter.utils.LogUtil;


public class DialogAddBaby extends Dialog implements
        View.OnClickListener {
    private Activity mContext;
    private Button btn_confirm;
    private TextView titleTxt;
    private TextView content;
    private String titleStr;
    private String limitDisposit;
    private String schoolName;
    private String schoolSysNo;
    private int rechargeType;
    private String contentStr;


    public DialogAddBaby(Activity context, String mtitle, String mcontent) {
        super(context);
        setContentView(R.layout.dialog_add_baby);
        mContext = context;
        titleStr = mtitle;
        contentStr = mcontent;
        Window window = getWindow();
        WindowManager.LayoutParams lp = window.getAttributes();
        WindowManager manager = (WindowManager) context
                .getSystemService(Context.WINDOW_SERVICE);

        DisplayMetrics dm = new DisplayMetrics();
        manager.getDefaultDisplay().getMetrics(dm);
        int width = dm.widthPixels;

        lp.width = (int) (0.8 * width);

        this.titleTxt = (TextView) findViewById(R.id.dialog_baby_title);
        this.content = (TextView) findViewById(R.id.dialog_baby_message);

        titleTxt.setText(mtitle);
        content.setText(mcontent);

        btn_confirm = (Button) findViewById(R.id.dialog_baby_btn);
        btn_confirm.setOnClickListener(this);
    }

    public DialogAddBaby(Activity context, String mtitle, String mcontent, String confirmString) {
        super(context);
        setContentView(R.layout.dialog_add_baby);
        mContext = context;
        titleStr = mtitle;
        Window window = getWindow();
        WindowManager.LayoutParams lp = window.getAttributes();
        WindowManager manager = (WindowManager) context
                .getSystemService(Context.WINDOW_SERVICE);

        DisplayMetrics dm = new DisplayMetrics();
        manager.getDefaultDisplay().getMetrics(dm);
        int width = dm.widthPixels;

        lp.width = (int) (0.8 * width);

        this.titleTxt = (TextView) findViewById(R.id.dialog_baby_title);
        this.content = (TextView) findViewById(R.id.dialog_baby_message);

        titleTxt.setText(mtitle);
        content.setText(mcontent);

        btn_confirm = (Button) findViewById(R.id.dialog_baby_btn);
        btn_confirm.setText(confirmString);
        btn_confirm.setOnClickListener(this);
    }

    public DialogAddBaby(Activity context, String mtitle, String mcontent, String confirmString, String schoolName, String schoolSysNo, String limitDisposit, int rechargeType) {
        super(context);
        setContentView(R.layout.dialog_add_baby);
        mContext = context;
        titleStr = mtitle;
        Window window = getWindow();
        WindowManager.LayoutParams lp = window.getAttributes();
        WindowManager manager = (WindowManager) context
                .getSystemService(Context.WINDOW_SERVICE);

        DisplayMetrics dm = new DisplayMetrics();
        manager.getDefaultDisplay().getMetrics(dm);
        int width = dm.widthPixels;

        lp.width = (int) (0.8 * width);

        this.titleTxt = (TextView) findViewById(R.id.dialog_baby_title);
        this.content = (TextView) findViewById(R.id.dialog_baby_message);

        titleTxt.setText(mtitle);
        content.setText(mcontent);

        btn_confirm = (Button) findViewById(R.id.dialog_baby_btn);
        btn_confirm.setText(confirmString);
        btn_confirm.setOnClickListener(this);
        this.schoolName = schoolName;
        this.schoolSysNo = schoolSysNo;
        this.limitDisposit = limitDisposit;
        this.rechargeType = rechargeType;
    }

    @Override
    public void onClick(View v) {

        LogUtil.MyLog("权限", "=====dasfas==asdfas");
        // TODO Auto-generated method stub
        if (ContextCompat.checkSelfPermission(mContext, Manifest.permission.CAMERA)
                != PackageManager.PERMISSION_GRANTED) {
            //申请WRITE_EXTERNAL_STORAGE权限
            ActivityCompat.requestPermissions(mContext, new String[]{Manifest.permission.CAMERA},
                    1);

            LogUtil.MyLog("权限", "=====dasfas==");
        }
    }

}
